package com.biz.primus.ms.cart.api;

import com.biz.primus.model.cart.vo.*;
import com.biz.primus.ms.cart.service.ShopCartService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ShopCartApiController
 *
 * @author jia JKLiues
 * @date 2017年09月20日
 * @reviewer
 * @see
 */
@RestController
@RequestMapping("soa/shopCartService")
public class ShopCartApiController {

    private final ShopCartService shopCartService;

    @Autowired
    ShopCartApiController(ShopCartService shopCartService) {
        this.shopCartService = shopCartService;
    }

    @ApiOperation(value = "购物车商品信息")
    @PostMapping("getShopCartInfo")
    public ShopCartRespVo getShopCartInfo(@RequestBody CartBaseReqVo reqVo) {
        return shopCartService.getShopCartInfo(reqVo);
    }

    @ApiOperation(value = "加入购物车")
    @PostMapping("addShopCartItem")
    public ShopCartRespVo addShopCartItem(@RequestBody ShopCartItemAddVo vo) {
        return shopCartService.addShopCartItem(vo);
    }

    @ApiOperation(value = "删除购物车商品")
    @PostMapping("deleteShopCartItems")
    public void deleteShopCartItems(@RequestBody CartProductListVo reqVo) {
        shopCartService.deleteShopCartItems(reqVo);
    }

    @ApiOperation("设置购物车选中商品")
    @PostMapping("selectedItem")
    public void selectedItem(@RequestBody ShopCartItemCheckVo vo) {
        shopCartService.selectedItem(vo);
    }

    @ApiOperation("获取购物车商品数量")
    @PostMapping("getShopCartNum")
    public ShopCartNumRespVo getShopCartNum(@RequestBody CartBaseReqVo reqVo) {
        return shopCartService.getShopCartNum(reqVo);
    }
}